//
//  EarningsCell.m
//  JiFengDaRen
//
//  Created by zhuchao on 16/5/15.
//  Copyright © 2016年 SH_iOS. All rights reserved.
//

#import "EarningsCell.h"
#import "EarningsTimeModel.h"
#import "UserModel.h"
@implementation EarningsCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubView];
    }
    
    return self;
    
    
}

- (void)createSubView{
    
    self.todayEarningLabel = [[UILabel alloc]init];
    self.todayEarningLabel.text = @"0.00";
    self.todayEarningLabel.font = KSystemFont(__I6Width(15));
    self.todayEarningLabel.textColor = KREDCOLOR;
    [self.contentView addSubview:self.todayEarningLabel];
    
     
    self.totalEarningLabel  = [[UILabel alloc]init];
    self.totalEarningLabel.text = @"0.00";
    self.totalEarningLabel.font = KSystemFont(__I6Width(12));
    self.totalEarningLabel.textColor = KTEXTCOLOR;
    self.totalEarningLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.totalEarningLabel];
    
    
    
    self.dataLabel  = [[UILabel alloc]init];
    self.dataLabel.text = @"年 月 日";
    self.dataLabel.font = KSystemFont(__I6Width(11));
    self.dataLabel.textAlignment = NSTextAlignmentRight;
    self.dataLabel.textColor = [UIColor colorWithHexString:@"#999999"];
    [self.contentView addSubview:self.dataLabel];
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = KLINECOLOR;
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(0);
        make.left.mas_equalTo(self.contentView.mas_left).with.offset(__I6Width(15));
        make.width.mas_equalTo(KScreenWidth - __I6Width(15));
        make.height.mas_equalTo(0.5);
    }];
   
    
}
-(void)layoutSubviews{
    
    [self.todayEarningLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(self.contentView.mas_left).with.offset(__I6Width(15));
        make.width.mas_equalTo(__I6Width(200));
        make.height.mas_equalTo(__I6Height(17));
    }];
    
    [self.totalEarningLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.contentView.mas_top).with.offset(__I6Height(15));
        make.right.mas_equalTo(self.contentView.mas_right).with.offset(__I6Width(-15));
        make.width.mas_equalTo(__I6Width(200));
        make.height.mas_equalTo(__I6Height(12));
    }];

    
    [self.dataLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.totalEarningLabel.mas_bottom).with.offset(__I6Height(15));
        make.right.mas_equalTo(self.contentView.mas_right).with.offset(__I6Width(-15));
        make.width.mas_equalTo(__I6Width(200));
        make.height.mas_equalTo(__I6Height(11));
    }];
    
   

}
-(void)setModel:(EarningsTimeModel *)model{
    
    NSArray *dateArr = [model.earningsTime componentsSeparatedByString:@" "];
    NSString *year_monte_day = [dateArr firstObject];
    NSArray *hour_minite_s = [[dateArr lastObject] componentsSeparatedByString:@":"];
    NSString *hour_minite  = [NSString stringWithFormat:@"%@:%@",[hour_minite_s firstObject],hour_minite_s[1]];
    self.dataLabel.text = [NSString stringWithFormat:@"%@ %@",year_monte_day,hour_minite];
    self.totalEarningLabel.text = [NSString stringWithFormat:@"总收益 ¥%.2f",model.totalEarnings];
 
    self.todayEarningLabel.text = [NSString stringWithFormat:@"+%.2f",model.yesTDEarnings];
    
}
-(void)setShareProfitModel:(ShareProfitModel *)shareProfitModel{
    
    
    NSArray *dateArr = [shareProfitModel.time componentsSeparatedByString:@" "];
    NSString *year_monte_day = [dateArr firstObject];
    NSArray *hour_minite_s = [[dateArr lastObject] componentsSeparatedByString:@":"];
    NSString *hour_minite  = [NSString stringWithFormat:@"%@:%@",[hour_minite_s firstObject],hour_minite_s[1]];
    self.dataLabel.text = [NSString stringWithFormat:@"%@ %@",year_monte_day,hour_minite];
 
    self.totalEarningLabel.text = shareProfitModel.memo;
   
    self.todayEarningLabel.text = [NSString stringWithFormat:@"%.2f",shareProfitModel.amount];
}
- (void)setTradeModel:(TradeModel *)tradeModel{
    
    
    
    NSArray *dateArr = [tradeModel.time componentsSeparatedByString:@" "];
    NSString *year_monte_day = [dateArr firstObject];
    NSArray *hour_minite_s = [[dateArr lastObject] componentsSeparatedByString:@":"];
    NSString *hour_minite  = [NSString stringWithFormat:@"%@:%@",[hour_minite_s firstObject],hour_minite_s[1]];
    self.dataLabel.text = [NSString stringWithFormat:@"%@ %@",year_monte_day,hour_minite];
    
    self.totalEarningLabel.text = tradeModel.status;
    
    self.todayEarningLabel.text = [NSString stringWithFormat:@"%@%@元",tradeModel.using_type,tradeModel.amount];
    self.dataLabel.text = [NSString stringWithFormat:@"%@ %@",year_monte_day,hour_minite];
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
    [super setHighlighted:highlighted animated:animated];
    if (highlighted) {
        self.backgroundColor = KCELLHIGHTLIGHTED;
    }else{
        self.backgroundColor = [UIColor whiteColor];
        
    }
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
    [super setSelected:selected animated:animated];
    
    if (selected) {
        self.backgroundColor = KCELLHIGHTLIGHTED;
    }else{
        self.backgroundColor = [UIColor whiteColor];
        
    }
    
    
}


@end
